 import React, {forwardRef, useContext, useState} from 'react'
 import { Input } from "antd";
 import CustomizeModal, {CustomizeModalButton, CustomizeModalContext} from "@common/presentational/CustomizeModal";
 import { inventoryRefundReject } from "@sagas/warehouse/refund";
 import {useDispatch} from "react-redux";
 
 const WarehouseRefundRejectReasonModal = props => {
     const [reason, setReason] = useState('')
     const dispatch = useDispatch()
     const { hide, params } = useContext(CustomizeModalContext)
     const { applyNumber } = params
     const { callback } = props
 
     const handleReasonChange = e => setReason(e.currentTarget.value)
 
     const handleSubmit = () => {
         dispatch(inventoryRefundReject({
             applyNumber,
             reason,
             operation: 'reject',
         }, () => {
             callback && callback()
             hide()
         }))
     }
 
     return (
         <>
             <Input.TextArea value={reason}
                             onChange={handleReasonChange}
                             rows={4}
                             placeholder="请输入拒绝原因"
                             style={{resize: 'none' }}
             />
             <CustomizeModalButton
                 onOk={handleSubmit}
                 onCancel={hide}
             />
         </>
     )
 }
 
 
 export default forwardRef((props, ref) => (
     <CustomizeModal title="拒绝原因" ref={ref}>
         <WarehouseRefundRejectReasonModal {...props}/>
     </CustomizeModal>
 ))
 